<?php


class search extends CI_Controller{
     function __construct() {
        parent::__construct();
        $this->load->model('connect');
        $this->load->library('session');
    }
    function index(){
       $this->load->view('result'); 
    }
    function search1(){
         $this->session->unset_userdata('search');
        $s = $this->connect->search1($_GET['gender'],$_GET['age-one'],$_GET['age-two'],$_GET['city']);
        $this->session->set_userdata('search',$s);
        $this->load->view('result');
    }
    function searchcity(){
         $this->session->unset_userdata('search');
        $s = $this->connect->searchcity($this->session->userdata('city'));
        $this->session->set_userdata('search',$s);
        $this->load->view('result');
    }
            
    function  searchpage(){
        $this->session->unset_userdata('search');
        $s = $this->connect->search($_GET['gender'],$_GET['age-one'],$_GET['age-two'],$_GET['city'],$_GET['mucdich'],$_GET['height-one'],$_GET['height-two'],$_GET['weight-one'],$_GET['weight-two']);
        $this->session->set_userdata('search',$s);
        $this->load->view('result');
    }
    function searchbox(){
        

        $s = $this->connect->searchbox($_POST['kw']);
        $count = count($s);
      

        if ($count > 0) {
            echo "<ul class='unli'>";
            foreach ($s as $y){
                 $id = $y->user_id;
                 $ten = $y->name;
                 $anh = $y->avarta;
                 $city= $y->city;
                 echo "<a class='sr' href='" . base_url('getID?id=' . $id). "'>";
                 echo "<li class='search-results'>";
                
               
                echo "<div class='anhdaidien2'>";
                echo "<img class= 'anhnho3 img-thumbnail' src='http://localhost:8080/nfa/images/avarta/" . $anh . "' >";
                
                echo "</div>";
                echo "<div class ='ten2'  >"; 
                echo "<p style='color: #003399; font-weight: bold;'>" .$ten . "</p>";
                echo "<p style='color: #999 ;' >" .$city . "</p>";
                echo "</div>";
               
               
                echo "</li>";
                 echo "</a>";
               
            }
            echo "</ul>";
            if ($count > 5) {
                echo "<div id='view_more'><a onclick='searchSubmit();'>Hiển thị tất cả kết quả</a></div>";
            }
        } else {
            echo "<div id='no_result'>Không tìm thấy !</div>";
        }
    }
    function searchquick(){
         $this->session->unset_userdata('search');
        $a = $this->connect->searchbox($_GET['kw']);
        $this->session->set_userdata('search',$a);
        $this->load->view('result');
    }
    
}

?>
